package com.JackTang.fruit.servlets;

import com.JackTang.fruit.dao.FruitDAO;
import com.JackTang.fruit.dao.impl.FruitDAOImpl;
import com.myssm.myspringmvc.ViewBaseServlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author Jack Tang
 * @description
 * @create 2023-05-05 21:28
 */
@WebServlet("/del.do")
public class DelServlet extends ViewBaseServlet {
    private FruitDAO fruitDAO = new FruitDAOImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String fidStr = req.getParameter("fid");
        int fid = Integer.parseInt(fidStr);
        fruitDAO.deleteFruit(fid);

        resp.sendRedirect("index");
    }
}